﻿using MovingChame.WindowsStoreApp.Common;
using MovingChameLibrary.Models;
using MovingChameLibrary.ViewModels;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace MovingChame.WindowsStoreApp.UIModule
{
    public sealed partial class TourSchedulePage : LayoutAwarePage
    {
        public TourScheduleViewModel _viewModel;
        public TourScheduleViewModel ViewModel
        {
            get { return this._viewModel; }
            set
            {
                this._viewModel = value;
                this.DataContext = value;
            }
        }

        public TourSchedulePage()
        {
            this.InitializeComponent();
        }

        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey("SelectedLocation"))
            {
                navigationParameter = pageState["SelectedLocation"];
            }
            ViewModel = new TourScheduleViewModel((Schedule)navigationParameter);
            this.flipView.SelectedItem = ViewModel.SelectedItem;
        }

        protected override void SaveState(Dictionary<String, Object> pageState)
        {
            Schedule selectedItem = (Schedule)this.flipView.SelectedItem;
            pageState["SelectedLocation"] = selectedItem;
        }
    }
}
